package staticDemo;

public class ConstructorTest3 {
    public static void main(String[] args) {
        // 目标：掌握在类的构造器中，通过this(...)调用兄弟构造器的作用

        Student3 s3 = new Student3("张三", 28, "清北");
        System.out.println(s3.getName());
        System.out.println(s3.getAge());
        System.out.println(s3.getSchoolName());

        System.out.println("---------------------------------");

        // 需求：如果学生没有填写学校，那么学校默认就是黑马程序员
        Student3 s33 = new Student3("刘刘", 28);

        System.out.println(s33.getName());
        System.out.println(s33.getAge());
        System.out.println(s33.getSchoolName());
    }
}

class Student3 {
    private String name;
    private int age;
    private String schoolName;

    public Student3() {
    }

    public Student3(String name, int age) {
        this(name, age, "黑马程序员");
    }

    public Student3(String name, int age, String schoolName) {
        this.name = name;
        this.age = age;
        this.schoolName = schoolName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSchoolName() {
        return schoolName;
    }

    public void setSchoolName(String schoolName) {
        this.schoolName = schoolName;
    }
}
